package com.homson.coreservice.serviceinfrastructure.datasource.model.account;

import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.Objects;

/**
 * @author: homson_leo
 * @contact: hey_超级巨星（Homson_Leo）- 刘泓岑 1196816884@qq.com
 * @time: 2025/10/2 09:20 AM
 
 **/
@Data
@NoArgsConstructor
@Accessors(chain = true)
@TableName("account")
public class AccountDO extends BaseAccount{
    
    private Long userId;
    private String name; // 账户名称
    private String type; // 账户一级类型（BANK/ONLINE/INVESTMENT/LOAN）
    private String currency;
    private BigDecimal balance;
    private LocalDateTime lastUpdated;
    private Long versionId;
    
    public void incrementVersionId() {
        if(Objects.isNull(this.versionId)){
            this.versionId = 0L;
        }
        this.versionId += 1L;
    }
    
    public void lastUpdated() {
        this.lastUpdated = LocalDateTime.now();
    }
    
}
